<?php
/**
 * TbSyncLog.php class file.
 * @author shengxia <523247758@qq.com>
 * @date 2021/01/06- 5:13 下午
 */

namespace common\models;
use common\models\pdd\PddBatchSyncLog as BasePddSyncLog;

class PddBatchSyncLog extends BasePddSyncLog
{
    /**
     * 获取批量修改记录列表
     * @param int $page
     * @param int $pageSize
     * @param array $args
     * @return array
     */
    public function getListPage(int $page = 1, int $pageSize = 10, array $args = [])
    {

        $query = PddBatchSyncLog::find();
        //$query->select(['batchType', 'type', 'status', 'batch_no', 'goods_id', 'error_info', 'aftercontent', 'beftercontent']);
        if (count($args)) {
            $offset = ($page - 1) * $pageSize;
            /**
             * 默认按照id 倒叙排序
             */
            if (isset($args['uid'])) {
                $query->where(['uid' => $args['uid']]);
            }
            if (isset($args['mall_id'])) {
                $query->where(['mall_id' => $args['mall_id']]);
            }
            $query->orderBy('created_at DESC');
            $count = $query->count();
            $query->limit($pageSize)->offset($offset);
            $list = $query->all();
        }
        return [$count, $list];

    }
}
